import request from "@/utils/request";
export const service = "/ttadmin";

export const TR = async (promise) => {
  try {
    const res = await promise;
    return [null, res];
  } catch (e) {
    return [e, null];
  }
};

// 组件标签列表查询
export const findByCondition = (params) =>
  TR(request.post(service + "/componentTag/findByCondition", params));

// 组件标签管理：新增/编辑组件标签
export function saveOrUpdateComponentTags(param) {
  return request({
    url: service + "/componentTag/saveOrUpdateComponentTags",
    method: "post",
    data: param,
  });
}

// 组件标签删除
export const deleteComponentTag = (params) =>
  TR(request.post(service + "/componentTag/deleteComponentTag", params));

// 组件标签管理：校验标签是否被组件使用
export const componentTagIsInUse = (params) =>
  TR(request.post(service + "/componentTag/componentTagIsInUse", params));

// 标签类型列表查询
export const listComponentTagTypes = (params) =>
  TR(request.post(service + "/componentTag/listComponentTagTypes", params));

// 标签类型列表新增/编辑
export const insertOrUpdateTagTypes = (params) =>
  TR(request.post(service + "/componentTag/insertOrUpdateTagTypes", params));

// 标签类型管理：标签类型删除
export const deleteComponentTagType = (params) =>
  TR(request.post(service + "/componentTag/deleteComponentTagType", params));

// 标签类型管理：校验该标签类型下是否已有标签
export const checkComponentTagTypeEmpty = (params) =>
  TR(
    request.post(service + "/componentTag/checkComponentTagTypeEmpty", params)
  );

// 获取标签类型颜色列表
export const componentTagTypeColors = (params) =>
  TR(request.post(service + "/componentTag/componentTagTypeColors", params));

// 标签类型管理：校验标签类型名称是否重复
export const componentTagTypeIsExists = (params) =>
  TR(request.post(service + "/componentTag/componentTagTypeIsExists", params));
